<template>
  <div class="tabbar">
    <transition name="fade">
      <router-view />
    </transition>
    <van-tabbar v-model="active" safe-area-inset-bottom>
      <van-tabbar-item name="msite" icon="logistics" replace :to="'/msite?geohash='+geohash">外卖</van-tabbar-item>
      <van-tabbar-item name="search" icon="search" replace :to="'/search/'+geohash">搜索</van-tabbar-item>
      <van-tabbar-item
        name="order"
        icon="description"
        replace
        to="/order"
        :info="$store.getters.getCarCount"
      >订单</van-tabbar-item>
      <van-tabbar-item name="profile" icon="contact" replace to="/profile">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "tabbar",
  data() {
    return {
      active: 'msite',
      info: 0
    };
  },
  computed: {
    ...mapState(["geohash"])
  },
  created() {
    // const arr = this.geohash.split(","); //将经纬度分割
    this.active = this.$route.name;
    window.console.log(this.active);
    // this.$store.commit("setGeohash", this.$route.query.geohash); //保存经纬度
  }
};
</script>

<style lang="stylus" scoped>
.van-tabbar {
  border-top: 1px solid #EBEBEB;
  margin-top: 50px;
}

.tabbar {
  overflow-x: hidden;
}

.fade-enter {
  transform: translateX(100%);
  opacity: 0;
}

.fade-levave-to {
  transform: translateX(-100%);
  position: absolute;
  opacity: 0;
}

.fade-enter-active, .fade-levave-active {
  transition: all 0.2s;
}
</style>